package cn.wolfcode.wolf2w.controller;

import cn.wolfcode.wolf2w.domain.*;
import cn.wolfcode.wolf2w.service.*;
import cn.wolfcode.wolf2w.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/destinations")
public class DestinationController {

    @Autowired
    private IRegionService regionService;
    @Autowired
    private IDestinationService destinationService;
    @Autowired
    private IStrategyCatalogService strategyCatalogService;
    @Autowired
    private IStrategyService strategyService;
    @Autowired
    private ITravelService travelService;

    @RequestMapping("/hotRegion")
    public JsonResult<Region> hotRegion(){

        List<Region> list = regionService.hotRegion();
        return JsonResult.success(list);
    }

    @RequestMapping("/search")
    public JsonResult<Destination> search(String regionId){
        List<Destination> list = destinationService.search(regionId);
        return JsonResult.success(list);
    }

    @RequestMapping("/toasts")
    public Object toasts(String destId){
        List<Destination> list = destinationService.queryToasts(destId);
        return JsonResult.success(list);
    }

    @RequestMapping("/catalogs")
    public Object catalogs(String destId){
        //利用目的地id查询所有相关的攻略分类
        List<StrategyCatalog> list = strategyCatalogService.catalogs(destId);
        return JsonResult.success(list);
    }

    @RequestMapping("/strategies/viewnumTop3")
    public Object strategiesviewnumTop3(String destId){
        List<Strategy> list = strategyService.viewnumTop3(destId);
        return JsonResult.success(list);
    }

    @RequestMapping("/travels/viewnumTop3")
    public Object travelsviewnumTop3(String destId){
        List<Travel> list = travelService.travelsviewnumTop3(destId);
        return JsonResult.success(list);
    }



    @RequestMapping("/list")
    public Object lislt(){
        List<Destination> list =  destinationService.list();
        return JsonResult.success(list);
    }

}
